package com.lonely.web.controller.inventory;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lonely.common.core.domain.api.R;
import com.lonely.inventory.domain.dto.stockup.*;
import com.lonely.inventory.domain.vo.stockup.QueryAddStockUpInventoryPageVO;
import com.lonely.inventory.domain.vo.stockup.StockUpInventoryPageQueryVo;
import com.lonely.inventory.domain.vo.stockup.StockUpInventorySizeInfoVo;
import com.lonely.inventory.service.IStockUpInventoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author : 黄志标
 * @date: 2025/9/24 15:11
 * @description:
 */
@RestController
@RequestMapping("/inventoryManager/stockUpInventory")
@Api(tags = "库存管理/备货库存")
public class StockUpInventoryController {

    @Autowired
    private IStockUpInventoryService stockUpInventoryService;

    /**
     * 分页查询
     *
     * @param queryDto
     * @return
     */
    @PostMapping("/page")
    @ApiOperation(value = "分页查询")
    public R<Page<StockUpInventoryPageQueryVo>> page(@RequestBody StockUpInventoryPageQueryDto queryDto) {
        return R.data(this.stockUpInventoryService.page(queryDto));
    }


    /**
     * 新增备货库存时，根据条件查询商品列表
     *
     * @param queryDto
     * @return
     */
    @PostMapping("/addStockUpInventoryPage")
    @ApiOperation(value = "新增备货库存分页查询")
    public R<Page<QueryAddStockUpInventoryPageVO>> addStockUpInventoryPage(@RequestBody @Validated QueryAddStockUpInventoryPageDTO queryDto) {
        return R.data(this.stockUpInventoryService.addStockUpInventoryPage(queryDto));
    }

    /**
     * 新增备货库存
     *
     * @param submitDto
     * @return
     */
    @PostMapping("/addStockUpInventory")
    @SaCheckPermission("inventory:stockUpInventory:addStockUpInventory")
    public R<Boolean> addStockUpInventory(@RequestBody @Validated AddStockUpInventoryDTO submitDto) {
        this.stockUpInventoryService.addStockUpInventory(submitDto);
        return R.status(true);
    }

    /**
     * 根据备货库存id查询尺码明细信息
     *
     * @param stockUpInventoryId
     * @return
     */
    @GetMapping("/getStockUpInventorySizeInfoList/{stockUpInventoryId}")
    public R<List<StockUpInventorySizeInfoVo>> getStockUpInventorySizeInfoList(@PathVariable("stockUpInventoryId") Long stockUpInventoryId) {
        return R.data(this.stockUpInventoryService.getStockUpInventorySizeInfoList(stockUpInventoryId));
    }

    /**
     * 入库
     *
     * @param submitDto
     * @return
     */
    @PostMapping("/putStorage")
    @SaCheckPermission("inventory:stockUpInventory:putStorage")
    public R<Boolean> putStorage(@RequestBody @Validated SubmitStockUpInventorySizeDTO submitDto) {
        this.stockUpInventoryService.putStorage(submitDto);
        return R.status(true);
    }


    /**
     * 出库
     *
     * @param submitDto
     * @return
     */
    @PostMapping("/outStorage")
    @SaCheckPermission("inventory:stockUpInventory:outStorage")
    public R<Boolean> outStorage(@RequestBody @Validated SubmitStockUpInventorySizeDTO submitDto) {
        this.stockUpInventoryService.outStorage(submitDto);
        return R.status(true);
    }

    /**
     * 调拨
     *
     * @param submitDto
     * @return
     */
    @PostMapping("/transfer")
    @SaCheckPermission("inventory:stockUpInventory:transfer")
    public R<Boolean> transfer(@RequestBody @Validated TransferStockUpInventorySizeDTO submitDto) {
        this.stockUpInventoryService.transfer(submitDto);
        return R.status(true);
    }

    /**
     * 备货上架
     *
     * @param submitDto
     * @return
     */
    @PostMapping("/stockUpStockPutAway")
    public R<Boolean> stockUpStockPutAway(@RequestBody @Validated StockUpStockPutAwayDTO submitDto) {
        this.stockUpInventoryService.stockUpStockPutAway(submitDto);
        return R.data(true);
    }
}
